<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="format-detection" content="telephone=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="icon" href="/images/icons/favicon-16x16.png?v=2.8.0" type="image/png" sizes="16x16"><link rel="icon" href="/images/icons/favicon-32x32.png?v=2.8.0" type="image/png" sizes="32x32"><meta name="description" content="一.创建一个数采任务并执行                           1）创建一个项目        1.项目管理 -&gt; 输入项目名称、项目描述 2.创建数据源:  本示例创建mysql和clickhouse两个数据源,mysql数据源用来读取,clickhouse用来写入。  如何添加添加数据源:数据源管理 -&gt; 选择数据源:clic">
<meta property="og:type" content="article">
<meta property="og:title" content="datax执行数采任务示例">
<meta property="og:url" content="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/index.html">
<meta property="og:site_name" content="ljyxsg的技术成长录">
<meta property="og:description" content="一.创建一个数采任务并执行                           1）创建一个项目        1.项目管理 -&gt; 输入项目名称、项目描述 2.创建数据源:  本示例创建mysql和clickhouse两个数据源,mysql数据源用来读取,clickhouse用来写入。  如何添加添加数据源:数据源管理 -&gt; 选择数据源:clic">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E9%A1%B9%E7%9B%AE.example1.png">
<meta property="og:image" content="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E6%95%B0%E6%8D%AE%E6%BA%90%E9%85%8D%E7%BD%AE.example2.png">
<meta property="og:image" content="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/DataX%E4%BB%BB%E5%8A%A1%E6%A8%A1%E6%9D%BF.example4.png">
<meta property="og:image" content="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E4%BB%BB%E5%8A%A1%E7%AE%A1%E7%90%86.example3.png">
<meta property="og:image" content="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E6%93%8D%E4%BD%9C%E4%BB%BB%E5%8A%A1.example5.png">
<meta property="article:published_time" content="2023-02-07T03:09:57.000Z">
<meta property="article:modified_time" content="2023-02-07T05:14:11.202Z">
<meta property="article:author" content="ljyxsg">
<meta property="article:tag" content="datax数采中间件">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E9%A1%B9%E7%9B%AE.example1.png"><title>datax执行数采任务示例 | ljyxsg的技术成长录</title><link ref="canonical" href="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/"><link rel="dns-prefetch" href="https://cdn.jsdelivr.net"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.12.1/css/all.min.css" type="text/css"><link rel="stylesheet" href="/css/index.css?v=2.8.0"><link rel="stylesheet" href="css/custom.css"><script>var Stun = window.Stun || {};
var CONFIG = {
  root: '/',
  algolia: undefined,
  assistSearch: undefined,
  fontIcon: {"prompt":{"success":"fas fa-check-circle","info":"fas fa-arrow-circle-right","warning":"fas fa-exclamation-circle","error":"fas fa-times-circle"},"copyBtn":"fas fa-copy"},
  sidebar: {"offsetTop":"20px","tocMaxDepth":6},
  header: {"enable":true,"showOnPost":true,"scrollDownIcon":false},
  postWidget: {"endText":true},
  nightMode: {"enable":true},
  back2top: {"enable":true},
  codeblock: {"style":"default","highlight":"light","wordWrap":false},
  reward: false,
  fancybox: false,
  zoomImage: {"gapAside":"20px"},
  galleryWaterfall: undefined,
  lazyload: false,
  pjax: undefined,
  externalLink: {"icon":{"enable":true,"name":"fas fa-external-link-alt"}},
  shortcuts: undefined,
  prompt: {"copyButton":"复制","copySuccess":"复制成功","copyError":"复制失败"},
  sourcePath: {"js":"js","css":"css","images":"images"},
};

window.CONFIG = CONFIG;</script><meta name="generator" content="Hexo 6.3.0"></head><body><div class="container" id="container"><header class="header" id="header"><div class="header-inner"><nav class="header-nav header-nav--fixed"><div class="header-nav-inner"><div class="header-nav-menubtn"><i class="fas fa-bars"></i></div><div class="header-nav-menu"><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/"><span class="header-nav-menu-item__icon"><i class="fas fa-home"></i></span><span class="header-nav-menu-item__text">首页</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/archives/"><span class="header-nav-menu-item__icon"><i class="fas fa-folder-open"></i></span><span class="header-nav-menu-item__text">归档</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/categories/"><span class="header-nav-menu-item__icon"><i class="fas fa-layer-group"></i></span><span class="header-nav-menu-item__text">分类</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/tags/"><span class="header-nav-menu-item__icon"><i class="fas fa-tags"></i></span><span class="header-nav-menu-item__text">标签</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/about/"><span class="header-nav-menu-item__icon"><i class="fas fa-address-card"></i></span><span class="header-nav-menu-item__text">关于</span></a></div></div><div class="header-nav-mode"><div class="mode"><div class="mode-track"><span class="mode-track-moon"></span><span class="mode-track-sun"></span></div><div class="mode-thumb"></div></div></div></div></nav><div class="header-banner"><div class="header-banner-info"><div class="header-banner-info__title">ljyxsg的技术成长录</div><div class="header-banner-info__subtitle">亿点点nice的ljy</div></div></div></div></header><main class="main" id="main"><div class="main-inner"><div class="content-wrap" id="content-wrap"><div class="content" id="content"><!-- Just used to judge whether it is an article page--><div id="is-post"></div><div class="post"><header class="post-header"><h1 class="post-title">datax执行数采任务示例</h1><div class="post-meta"><span class="post-meta-item post-meta-item--createtime"><span class="post-meta-item__icon"><i class="far fa-calendar-plus"></i></span><span class="post-meta-item__info">发表于</span><span class="post-meta-item__value">2023-02-07</span></span><span class="post-meta-item post-meta-item--updatetime"><span class="post-meta-item__icon"><i class="far fa-calendar-check"></i></span><span class="post-meta-item__info">更新于</span><span class="post-meta-item__value">2023-02-07</span></span></div></header><div class="post-body">
        <h2 id="一-创建一个数采任务并执行"   >
          <a href="#一-创建一个数采任务并执行" class="heading-link"><i class="fas fa-link"></i></a><a href="#一-创建一个数采任务并执行" class="headerlink" title="一.创建一个数采任务并执行"></a>一.创建一个数采任务并执行</h2>
      
        <h3 id="1）创建一个项目"   >
          <a href="#1）创建一个项目" class="heading-link"><i class="fas fa-link"></i></a><a href="#1）创建一个项目" class="headerlink" title="1）创建一个项目"></a>1）创建一个项目</h3>
      <ul>
<li>1.项目管理 -&gt; 输入项目名称、项目描述<img src="/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E9%A1%B9%E7%9B%AE.example1.png" class="" title="项目.example1"></li>
<li>2.创建数据源:<br>  本示例创建<code>mysql</code>和<code>clickhouse</code>两个数据源,<code>mysql</code>数据源用来读取,<code>clickhouse</code>用来写入。<br>  如何添加添加数据源:<code>数据源管理</code> -&gt; <code>选择数据源</code>:clickhouse -&gt; <code>输入数据源名称</code>:test -&gt; <code>用户名</code> -&gt; <code>密码</code> -&gt; <code>jdbc_url</code>:jdbc:clickhouse:&#x2F;&#x2F;192.168.13.46:8123&#x2F;default -&gt; <code>jbdc驱动类</code> -&gt; <code>测试连接</code>。如果出现连接成功的弹框,那说明数据源已经配置成功了。<img src="/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E6%95%B0%E6%8D%AE%E6%BA%90%E9%85%8D%E7%BD%AE.example2.png" class="" title="数据源配置.example2"></li>
<li>3.创建DataX任务模板:<code>添加</code> -&gt; <code>执行器</code> -&gt; <code>路由策略</code> -&gt; <code>阻塞处理</code> -&gt; <code>任务类型</code> -&gt; <code>所属项目</code> -&gt; <code>任务描述</code> -&gt; <code>Cron定时表达式</code> -&gt; <code>点击确认</code><img src="/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/DataX%E4%BB%BB%E5%8A%A1%E6%A8%A1%E6%9D%BF.example4.png" class="" title="DataX任务模板.example4"></li>
<li>4.任务构建(分为4个步骤)<ul>
<li>1.在<code>mysql</code>和<code>clickhouse</code>里创建示例表，表名和字段名均可不一致</li>
<li>1.构建reader:选择<code>数据库源</code> -&gt; <code>数据库表名</code> -&gt; 选择要读取的<code>表字段</code></li>
<li>2.构建writer:选择<code>数据库源</code> -&gt; <code>数据库表名</code> -&gt; 选择要写入的<code>表字段</code></li>
<li>3.字段映射:选择需要<code>读取字段和写入字段</code></li>
<li>4.<code>点击构建</code> -&gt; <code>选择模板</code><br>  创建完成可以在任务管理中找到任务记录。<img src="/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E4%BB%BB%E5%8A%A1%E7%AE%A1%E7%90%86.example3.png" class="" title="任务管理.example3"></li>
</ul>
</li>
</ul>

        <h2 id="2）运行一次数采任务"   >
          <a href="#2）运行一次数采任务" class="heading-link"><i class="fas fa-link"></i></a><a href="#2）运行一次数采任务" class="headerlink" title="2）运行一次数采任务"></a>2）运行一次数采任务</h2>
      <ul>
<li><code>任务管理</code> -&gt; <code>操作</code> -&gt; <code>执行一次</code><img src="/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/%E6%93%8D%E4%BD%9C%E4%BB%BB%E5%8A%A1.example5.png" class="" title="操作任务.example5">
使用<code>dbeaver</code>连接<code>clickhouse</code>，可以看到数据已经采集完成。</li>
</ul>
</div><footer class="post-footer"><div class="post-ending ending"><div class="ending__text">------ 本文结束，感谢您的阅读 ------</div></div><div class="post-copyright copyright"><div class="copyright-author"><span class="copyright-author__name">本文作者: </span><span class="copyright-author__value"><a href="https://lou_jianyang.gitee.io">ljyxsg</a></span></div><div class="copyright-link"><span class="copyright-link__name">本文链接: </span><span class="copyright-link__value"><a href="https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/">https://lou_jianyang.gitee.io/2023/02/07/datax%E6%89%A7%E8%A1%8C%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E7%A4%BA%E4%BE%8B/</a></span></div><div class="copyright-notice"><span class="copyright-notice__name">版权声明: </span><span class="copyright-notice__value">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en" rel="external nofollow" target="_blank">BY-NC-SA</a> 许可协议。转载请注明出处！</span></div></div><div class="post-tags"><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="https://lou_jianyang.gitee.io/tags/datax%E6%95%B0%E9%87%87%E4%B8%AD%E9%97%B4%E4%BB%B6/">datax数采中间件</a></span></div><nav class="post-paginator paginator"><div class="paginator-prev"><a class="paginator-prev__link" href="/2023/02/09/%E4%BD%BF%E7%94%A8netty%E5%88%9B%E5%BB%BAhttp%E7%BD%91%E9%A1%B5%E8%81%8A%E5%A4%A9%E5%AE%A4/"><span class="paginator-prev__icon"><i class="fas fa-angle-left"></i></span><span class="paginator-prev__text">使用netty创建http网页聊天室</span></a></div><div class="paginator-next"><a class="paginator-next__link" href="/2023/02/07/datax%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AE%BE%E8%AE%A1/"><span class="paginator-prev__text">datax数据库设计</span><span class="paginator-next__icon"><i class="fas fa-angle-right"></i></span></a></div></nav></footer></div></div></div><div class="sidebar-wrap" id="sidebar-wrap"><aside class="sidebar" id="sidebar"><div class="sidebar-nav"><span class="sidebar-nav-toc current">文章目录</span><span class="sidebar-nav-ov">站点概览</span></div><section class="sidebar-toc"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80-%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1%E5%B9%B6%E6%89%A7%E8%A1%8C"><span class="toc-number">1.</span> <span class="toc-text">
          一.创建一个数采任务并执行</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1%EF%BC%89%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E9%A1%B9%E7%9B%AE"><span class="toc-number">1.1.</span> <span class="toc-text">
          1）创建一个项目</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%EF%BC%89%E8%BF%90%E8%A1%8C%E4%B8%80%E6%AC%A1%E6%95%B0%E9%87%87%E4%BB%BB%E5%8A%A1"><span class="toc-number">2.</span> <span class="toc-text">
          2）运行一次数采任务</span></a></li></ol></section><!-- ov = overview--><section class="sidebar-ov hide"><div class="sidebar-ov-author"><div class="sidebar-ov-author__avatar"><img class="sidebar-ov-author__avatar_img" src="/images/icons/stun-logo.svg" alt="avatar"></div><p class="sidebar-ov-author__text">Hello Stun</p></div><div class="sidebar-ov-state"><a class="sidebar-ov-state-item sidebar-ov-state-item--posts" href="/archives/"><div class="sidebar-ov-state-item__count">15</div><div class="sidebar-ov-state-item__name">归档</div></a><a class="sidebar-ov-state-item sidebar-ov-state-item--categories" href="/categories/"><div class="sidebar-ov-state-item__count">9</div><div class="sidebar-ov-state-item__name">分类</div></a><a class="sidebar-ov-state-item sidebar-ov-state-item--tags" href="/tags/"><div class="sidebar-ov-state-item__count">2</div><div class="sidebar-ov-state-item__name">标签</div></a></div><div class="sidebar-ov-cc"><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en" target="_blank" rel="noopener" data-popover="知识共享许可协议" data-popover-pos="up"><img src="/images/cc-by-nc-sa.svg"></a></div></section><div class="sidebar-reading"><div class="sidebar-reading-info"><span class="sidebar-reading-info__text">你已阅读了 </span><span class="sidebar-reading-info__num">0</span><span class="sidebar-reading-info__perc">%</span></div><div class="sidebar-reading-line"></div></div></aside></div><div class="clearfix"></div></div></main><footer class="footer" id="footer"><div class="footer-inner"><div><span>Copyright © 2023</span><span class="footer__icon"><i class="fas fa-heart"></i></span><span>ljyxsg</span></div><div><span>由 <a href="http://hexo.io/" title="Hexo" target="_blank" rel="noopener">Hexo</a> 强力驱动</span><span> v6.3.0</span><span class="footer__devider">|</span><span>主题 - <a href="https://github.com/liuyib/hexo-theme-stun/" title="Stun" target="_blank" rel="noopener">Stun</a></span><span> v2.8.0</span></div></div></footer><div class="loading-bar" id="loading-bar"><div class="loading-bar__progress"></div></div><div class="back2top" id="back2top"><span class="back2top__icon"><i class="fas fa-rocket"></i></span></div></div><script src="https://cdn.jsdelivr.net/npm/jquery@v3.4.1/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.ui.min.js"></script><script src="/js/utils.js?v=2.8.0"></script><script src="/js/stun-boot.js?v=2.8.0"></script><script src="/js/scroll.js?v=2.8.0"></script><script src="/js/header.js?v=2.8.0"></script><script src="/js/sidebar.js?v=2.8.0"></script></body></html>